import request from '@/utils/request'

//------------------------文章接口---------------------------

// 文章列表
export function listArticle(params) {
    return request({
        url: '/api/article',
        method: 'get',
        params: params
    })
}

// 热门文章
export function hotArticle() {
    return request({
        url: '/api/article/hot',
        method: 'get',
        params: {}
    })
}

//------------------------分类接口---------------------------

// 分类
export function listCategory() {
    return request({
        url: '/api/category',
        method: 'get',
        params: {}
    })
}

// 分类树
export function listCategoryTree() {
    return request({
        url: '/api/category/tree',
        method: 'get',
        params: {}
    })
}

//------------------------标签接口---------------------------

// 标签
export function listTag() {
    return request({
        url: '/api/tag',
        method: 'get',
        params: {}
    })
}

//------------------------友链接口---------------------------

// 友链
export function listFriendChain() {
    return request({
        url: '/api/friendChain',
        method: 'get',
        params: {}
    })
}

//------------------------源码接口---------------------------

// 下载量排名前五的源码
export function topDownloadSource() {
    return request({
        url: '/api/source/listByDownload',
        method: 'get',
        params: {}
    })
}

// 查询源码
export function listSource(params) {
    return request({
        url: '/api/source',
        method: 'get',
        params: params
    })
}

//------------------------网站配置接口---------------------------

// 网站配置
export function getWebInfo() {
    return request({
        url: '/common/webInfo',
        method: 'get',
        params: {}
    })
}

export function report() {
    return request({
        url: '/common/report',
        method: 'get',
        params: {}
    })
}

//------------------------工具接口---------------------------

// 查询工具
export function listTool(params) {
    return request({
        url: '/api/tool',
        method: 'get',
        params: params
    })
}

//------------------------通知接口---------------------------
// 查询通知
export function listNotice(params) {
    return request({
        url: '/api/notice',
        method: 'get',
        params: params
    })
}

//------------------------文件接口---------------------------

// 文件上传
export function uploadFile(file) {
    const formData = new FormData();
    formData.append("file", file);
    return request({
        url: '/file/upload',
        method: 'post',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data: formData
    })
}

//------------------------公共接口---------------------------

// 验证码
export function getCaptcha(file) {
    const formData = new FormData();
    formData.append("file", file);
    return request({
        url: '/common/captcha',
        method: 'get',
        params: {}
    })
}
